package com.four.reimbursemanage.dao;

import com.four.reimbursemanage.entity.EntertainApply;
import com.four.reimbursemanage.entity.Payapply;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface EntertainApplyDao {

    /**
     * 查询招待费月统计列表
     *
     * @return 支付申请集合
     */
    @Select("<script>" +
            "SELECT * FROM entertain_apply" +
            "<where>" +
            "    <if test=\"month != null\">" +
            "      and month = #{month}" +
            "   </if>" +
            "    <if test=\"is_settlement != null\">" +
            "      and is_settlement = #{is_settlement}" +
            "   </if>" +
            "</where>" +
            "limit #{start}, #{size}" +
            "</script>")
    public List<EntertainApply> selectEntertainApplyList(int start, int size, Date month, Integer is_settlement);

    /*分页*/
    @Select("<script>" +
            "SELECT count(*) FROM entertain_apply" +
            "<where>" +
            "    <if test=\"month != null\">" +
            "      and month = #{month}" +
            "   </if>" +
            "    <if test=\"is_settlement != null\">" +
            "      and is_settlement = #{is_settlement}" +
            "   </if>" +
            "</where>" +
            "</script>")
    public int countEntertainApply( Date month, Integer is_settlement);

    /*修改结算状态*/
    @Update("<script>" +
            "update  entertain_apply " +
            "        <set>" +
            "            <if test=\"null!= is_settlement\">" +
            "                is_settlement =#{is_settlement}," +
            "            </if>" +
            "        </set>" +
            "        where id =#{id}" +
            "</script>")
    public int updateSettlement(EntertainApply entertainApply);
}
